package com.maven.blog.model;


import com.maven.blog.constant.Constant;
import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String msg;
    private T data;

//  业务执⾏成功时返回的⽅法

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(Constant.RESULT_CODE_SUCCESS);
        result.setMsg("");
        result.setData(data);
        return result;
    }

    //    业务执⾏失败时返回的⽅法
    public static Result fail( String msg) {
        Result result = new Result();
        result.setCode(Constant.RESULT_CODE_FAIL);
        result.setMsg(msg);
        result.setData("");
        return result;
    }

    //  ⽤⼾未登录时返回的⽅法
    public static Result unlogin(String msg, Object data) {
        Result result = new Result();
        result.setCode(Constant.RESULT_CODE_UNLOGIN);
        result.setMsg("⽤⼾未登录");
        result.setData(data);
        return result;
    }
}

